* CPS Final
* Analysis for "Peacekeepers without helmets: How violence shapes local peacebuilding by civilian peacekeepers"
* Authors: Hannah Smidt & Allard Duursma
* Note: The unit of analysis is the locality-month

set more off
version 13.0

capture cd "SET YOUR DIRECTORY WHERE YOU SAVED THE BELOW DATA FILE"

use "2022_11_07_dataFinal_max_agg_MonEv.dta", clear

set scheme plotplainblind

drop if year==2018 & month>=11

gen date = ym(year, month)
drop if date==.

egen id_str = concat(admin1Name admin2Name admin3Name admin3RefN)
encode id_str, gen(id)

duplicates tag id date, gen(tag)
list id admin1Name admin3RefN admin2Name admin3Name year month date if tag>0

* For linear models
capture gen ACLED_viol_any_ln = log(ACLED_viol_any+0.01)
capture gen ACLED_viol_any_l1_ln = log(ACLED_viol_any_l1+0.01)
capture gen LocalPeacebuild_AnyAss_ln = log(LocalPeacebuild_AnyAssistance+0.01)
capture gen un_military_ln = log(un_military+0.01)
capture gen un_military_l1_ln = log(un_military_l1+0.01)

* Labels
label var LocalPeacebuild_AnyAssistance "Local peacebuilding"
label var LocalPeacebuild_AnyAss_ln "Local peacebuilding logged"

label var SocialCohesion_AnyAssistance "PB for Reconciliation"
label var ConflictManage_AnyAssistance "PB for Conflict management"
label var StateAuthority_AnyAssistance "PB for State authority extension"
label var POC_AnyAssistance "PB for Protection of civilians"

label var ACLED_viol_any "All violence (ACLED)"
label var ACLED_viol_any_l1 "All violence (ACLED), lag 1m"
label var ACLED_viol_any_l2 "All violence (ACLED), lag 2m"
label var ACLED_viol_any_ln "All violence (ACLED) ln"
label var ACLED_viol_any_l1_ln "All violence (ACLED) ln, lag 1m"

label var ACLED_violenceAgainstCiv "One-sided viol. (ACLED)"
label var ACLED_viol_stateBased "State-based viol. (ACLED)"
label var ACLED_viol_nonState "Non-state viol. (ACLED)"

label var un_military "UN military numbers"
label var un_military_ln "UN military numbers, ln"
label var un_military_l1 "UN military numbers, lag 1m"
label var un_military_l1_ln "UN military numbers, ln lag 1m"
label var un_military_base "UN military deployed"
label var un_military_base_l1 "UN military deployed, lag 1m"

label var roadDensity "Road density"
label var distToCapital "Distance to capital"
label var Shape_Area_adm2 "Geographic size"
label var Pop_density "Population density"
label var ethnicFract "Ethnic fractionalization"
label var MoslemGroupSize "Muslim population size"

label var FoodInsecurity "Food insecurity"
label var ACLED_viol_any_3m_MA "Violence 3m average"
label var ACLED_viol_any_3m_MA_l1 "Violence 3m average, lag 1m" 
label var ACLED_viol_any_3m_MA_l2 "Violence 3m average, lag 2m" 
label var ACLED_NSA_Takes_Terr_cumsum "Non-state armed actor" 
label var ACLED_NSA_Takes_Terr_cumsum_l1 "Non-state armed actor, lag 1m"
label var anyCheckpoint "Roadblocks"

label var Diamonds "Diamonds"
label var diamondRoughPrice "Price"
label var distToBorder "Distance to border"

* Set directory for tables and figures
capture cd "SET YOUR DIRECTORY"

* Summary statistics
estpost sum LocalPeacebuild_AnyAssistance LocalPeacebuild_AnyAss_ln ///
SocialCohesion_AnyAssistance ConflictManage_AnyAssistance StateAuthority_AnyAssistance POC_AnyAssistance ///
ACLED_viol_any ACLED_viol_any_l1 ACLED_viol_any_l2 ///
ACLED_violenceAgainstCiv ACLED_viol_nonState ACLED_viol_stateBased ///
un_military_base un_military_base_l1 un_military  un_military_l1  ///
roadDensity distToCapital Shape_Area_adm2 Pop_density ethnicFract MoslemGroupSize FoodInsecurity ///
ACLED_viol_any_3m_MA ACLED_viol_any_3m_MA_l1 ///
ACLED_NSA_Takes_Terr_cumsum ACLED_NSA_Takes_Terr_cumsum_l1 anyCheckpoint ///
Diamonds diamondRoughPrice distToBorder
esttab using "Tables/Table_summary.rtf", replace cells("count(fmt(%12.0fc)) mean(fmt(%12.3fc)) sd(fmt(%12.3fc)) min(fmt(%12.3fc)) max(fmt(%12.3fc))") noobs label 


* Set panel data
tsset id date, monthly
* Number of obs=5,950 


* Control variables for different models
global controls roadDensity distToCapital Shape_Area_adm2 Pop_density FoodInsecurity ethnicFract MoslemGroupSize ACLED_viol_any_3m_MA anyCheckpoint
global controls_fe FoodInsecurity ACLED_viol_any_3m_MA anyCheckpoint

global controlsl1 roadDensity distToCapital Shape_Area_adm2 Pop_density FoodInsecurity ethnicFract MoslemGroupSize ACLED_viol_any_3m_MA_l1 anyCheckpoint
global controls_fel1 FoodInsecurity ACLED_viol_any_3m_MA_l1 anyCheckpoint

global controls_med roadDensity distToCapital Shape_Area_adm2 Pop_density FoodInsecurity ethnicFract MoslemGroupSize ACLED_viol_any_3m_MA_l2 
global controls_med_contemp roadDensity distToCapital Shape_Area_adm2 Pop_density FoodInsecurity ethnicFract MoslemGroupSize ACLED_viol_any_3m_MA

global controls_iv roadDensity distToCapital Shape_Area_adm2 Pop_density FoodInsecurity ethnicFract MoslemGroupSize ACLED_viol_any_3m_MA anyCheckpoint
global controls_feiv  FoodInsecurity  ACLED_viol_any_3m_MA anyCheckpoint

global controls_ucdp roadDensity distToCapital Shape_Area_adm2 Pop_density FoodInsecurity ethnicFract MoslemGroupSize UCDP_viol_any_3m_MA anyCheckpoint
global controls_ucdp2 roadDensity distToCapital Shape_Area_adm2 Pop_density FoodInsecurity ethnicFract MoslemGroupSize UCDP_viol_any_3m_MA 
global controls_ucdp_fe FoodInsecurity UCDP_viol_any_3m_MA anyCheckpoint


*************************************************************************************************
*************************************************************************************************
*** Hypothesis 1: Models of local peacebuilding with contemporaneous and previous violence
*************************************************************************************************
*************************************************************************************************

*********************************************
** Main Ms Table 1 and Appendix Table B1 ****
*********************************************

* Model 1a
nbreg LocalPeacebuild_AnyAssistance ACLED_viol_any, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/Table1.doc", replace  ctitle(Model 1a) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

* Model 1a
nbreg LocalPeacebuild_AnyAssistance ACLED_viol_any $controls, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/Table1.doc", append  ctitle(Model 1b) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

* Estimates for plot 
capture drop estimate
capture drop upper
capture drop lower
capture drop yaxis
gen yaxis = 4 in 1
replace yaxis = 3 in 2
replace yaxis = 2 in 3
replace yaxis = 1 in 4
gen estimate = .
gen upper = .
gen lower = .
quietly: nbreg LocalPeacebuild_AnyAssistance ACLED_viol_any $controls, vce(cl id)
margins, predict(n) at(ACLED_viol_any = (0 1) (mean) _all) contrast(atcontrast(r)) post
matrix myV = e(V)
matrix myB = e(b)
replace estimate = myB[1,1] in 1
replace upper = myB[1,1] + sqrt(myV[1,1])*1.96 in 1
replace lower = myB[1,1] - sqrt(myV[1,1])*1.96 in 1
						
* Model 1c
set seed 0000
xtnbreg LocalPeacebuild_AnyAssistance ACLED_viol_any $controls_fe, fe vce(bootstrap, reps(100)) 
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/Table1.doc", append ctitle(Model 1c) label dec(3) addtext(Location FE, Yes) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

* Estimates for plot
set seed 0000
quietly: xtnbreg LocalPeacebuild_AnyAssistance ACLED_viol_any $controls_fe, fe vce(bootstrap, reps(100)) 
margins, predict(nu0) at(ACLED_viol_any = (0 1) (mean) _all) contrast(atcontrast(r)) post
matrix myV = e(V)
matrix myB = e(b)
replace estimate = myB[1,1] in 2
replace upper = myB[1,1] + sqrt(myV[1,1])*1.96 in 2
replace lower = myB[1,1] - sqrt(myV[1,1])*1.96 in 2

* For comparison of substantive effects
nbreg LocalPeacebuild_AnyAssistance ACLED_viol_any $controls, vce(cl id)
sum anyCheckpoint
margins, predict(n) at(anyCheckpoint = (0.611 2.348) (mean) _all) contrast(atcontrast(r))


*********************************************
** Main Ms Table 2 and Appendix Table B2 ****
*********************************************

* Model 2a
nbreg LocalPeacebuild_AnyAssistance ACLED_viol_any_l1, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/Table2.doc", replace  ctitle(Model 2a) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

* Model 2b
nbreg LocalPeacebuild_AnyAssistance ACLED_viol_any_l1 $controlsl1, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/Table2.doc", append  ctitle(Model 2b) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

* Estimates for plot
quietly: nbreg LocalPeacebuild_AnyAssistance ACLED_viol_any_l1 $controlsl1, vce(cl id)
margins, predict(n) at(ACLED_viol_any_l1 = (0 1) (mean) _all) contrast(atcontrast(r)) post
matrix myV = e(V)
matrix myB = e(b)
replace estimate = myB[1,1] in 3
replace upper = myB[1,1] + sqrt(myV[1,1])*1.96 in 3
replace lower = myB[1,1] - sqrt(myV[1,1])*1.96 in 3

* Model 2c
set seed 0000
xtnbreg LocalPeacebuild_AnyAssistance ACLED_viol_any_l1 $controls_fel1, fe  vce(bootstrap, reps(100)) 
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/Table2.doc", append ctitle(Model 2c) label dec(3) addtext(Location FE, Yes) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

* Estimates for plot
set seed 0000
quietly:  xtnbreg LocalPeacebuild_AnyAssistance ACLED_viol_any_l1 $controls_fel1, fe vce(bootstrap, reps(100)) 
margins, predict(nu0) at(ACLED_viol_any_l1 = (0 1) (mean) _all) contrast(atcontrast(r)) post
matrix myV = e(V)
matrix myB = e(b)
replace estimate = myB[1,1] in 4
replace upper = myB[1,1] + sqrt(myV[1,1])*1.96 in 4
replace lower = myB[1,1] - sqrt(myV[1,1])*1.96 in 4

**********************************************************
* Make plot with results for H1
**********************************************************
twoway scatter yaxis estimate, msize(medlarge) || rspike upper lower yaxis, horizontal lwidth(medthick) lcolor(gray) ///
							ylabel(5 "Predicted difference" 4.8 "in peaebuilding events" 4.6 "for increase in:" ///
								   4.2 "violence (contemporaneous)" 4 "across locations (M1b)" ///
								   3.2 "violence (contemporaneous)" 3 "over time (M1c)" ///
								   2.2 "violence (1m lag)" 2 "across locations (M2b)" /// 
								   1.2 "violence (1m lag)" 1 "over time (M1c)", ///
							labsize(medsmall) labstyle(right) ) ///
							yscale(range(0.5 5) lstyle(none)) /// 
							xtitle("Effect size", size(medsmall) ) ytitle("") ///
							xlabel(-0.1(0.05)0.1, labsize(medsmall) ) xline(0)  ///
							legend( order(1 "Predicted value" 2 "95% CI") size(medsmall) ) 
graph export "./Figures/Figure_H1_all.png", replace

* Get effect size interpretation
tab estimate
sum LocalPeacebuild_AnyAssistance
di `r(sd)'/.0716841 




******************************************************************************
******************************************************************************
** Hypothesis 2: Mediation effect of violence through military deployment 
******************************************************************************
******************************************************************************

*********************************************
** Main Ms Table 3 and Appendix Table B3 ****
*********************************************

* Model effect of violence on UN military deployments
probit un_military_base_l1 ACLED_viol_any_l2 $controls_med, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/Table3_2MLag.doc", replace ctitle(Model 3a) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

* Model effect of violence and UN military deployments on civilian peacekeepers' peacebuilding efforts
nbreg LocalPeacebuild_AnyAssistance ACLED_viol_any_l2 un_military_base_l1 $controls_med, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/Table3_2MLag.doc", append ctitle(Model 3b) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)


* Model effect of violence on UN military personnel numbers
reg un_military_l1_ln ACLED_viol_any_l2 $controls_med, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/Table3_2MLag.doc", append ctitle(Model 3c) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

* Model effect of violence and UN military personnel numbers on civilian peacekeepers' peacebuilding efforts
set seed 4321
nbreg LocalPeacebuild_AnyAssistance ACLED_viol_any_l2 un_military_l1_ln $controls_med, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/Table3_2MLag.doc", append ctitle(Model 3d) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)


************************
** Main Ms Figure 8 ****
************************

* Merge average direct effect and average mediation effect (violence in contemporary month)
capture drop id_merge 
capture drop estimate upper lower
capture drop effects low up
gen id_merge = _n
merge m:1 id_merge using ".\MediationAnalysis\mediation_military_ci.dta"
drop _merge


* Make Y-Axis
capture drop yaxis
gen yaxis = 4 in 4
replace yaxis = 3 in 3
replace yaxis = 2 in 2
replace yaxis = 1 in 1

* Make scatter plot with mediation effects
twoway scatter yaxis effects, msize(medlarge) || rspike up low yaxis, horizontal lwidth(medthick) lcolor(gray) ///
							ylabel(4 "Mediation effect of" 3.8 "military personnel (1m lag) (M3d)" 3 "Direct effect" 2.8 "of violence (2m lag) (M3d)" ///
								   2 "Mediation effect of" 1.8 "military base (1m lag) (M3b)" 1 "Direct effect" 0.8 "of violence (2m lag) (M3b)", ///
							labsize(medsmall) labstyle(right) ) ///
							yscale(range(0.5 2.5) lstyle(none)) /// 
							xtitle("Effect size", size(medsmall) ) ytitle("") ///
							xlabel(-0.2(0.1)0.1, labsize(medsmall) ) xline(0)  ///
							legend( order(1 "Predicted value" 2 "95% CI") size(medsmall) ) 
graph export ".\Figures\Figure_H2.png", replace


 

******************************************************************************
******************************************************************************
** Hypothesis 3: Reverse causation *******************************************
******************************************************************************
******************************************************************************

************************
** Main Ms Figure 9 ****
************************

* First stage: Predicting violence with diamond export parameters
sort id date

* Create variables for nargin plot
capture drop myV myB 
capture drop upper lower estimate 
capture drop *axis
gen upper = . 
gen lower = .
gen estimate = .

* Check values for margin
sum diamondRoughPrice
sum distToBorder
di `r(mean)' - `r(sd)'

* Get marginal effects
reg ACLED_viol_any_ln c.Diamonds##c.diamondRoughPrice##c.distToBorder $controls_iv if KP_compliant==0, vce(cluster id)
margins, at(Diamonds = (0) diamondRoughPrice = (182 208) distToBorder = 20) contrast(atcontrast(r)) post 
matrix myV = e(V)
matrix myB = e(b)
replace estimate = myB[1,1] in 1
replace upper = myB[1,1] + sqrt(myV[1,1])*1.96 in 1
replace lower = myB[1,1] - sqrt(myV[1,1])*1.96 in 1

reg ACLED_viol_any_ln c.Diamonds##c.diamondRoughPrice##c.distToBorder $controls_iv if KP_compliant==0, vce(cluster id)
margins, at(Diamonds = (1) diamondRoughPrice = (182 208) distToBorder = 20)  contrast(atcontrast(r)) post 
matrix myV = e(V)
matrix myB = e(b)
replace estimate = myB[1,1] in 2
replace upper = myB[1,1] + sqrt(myV[1,1])*1.96 in 2
replace lower = myB[1,1] - sqrt(myV[1,1])*1.96 in 2

reg ACLED_viol_any_ln c.Diamonds##c.diamondRoughPrice##c.distToBorder $controls_iv if KP_compliant==0, vce(cluster id)
margins, at(Diamonds = (2) diamondRoughPrice = (182 208) distToBorder = 20) contrast(atcontrast(r)) post 
matrix myV = e(V)
matrix myB = e(b)
replace estimate = myB[1,1] in 3
replace upper = myB[1,1] + sqrt(myV[1,1])*1.96 in 3
replace lower = myB[1,1] - sqrt(myV[1,1])*1.96 in 3

reg ACLED_viol_any_ln c.Diamonds##c.diamondRoughPrice##c.distToBorder $controls_iv if KP_compliant==0, vce(cluster id)
margins, at(Diamonds = (3) diamondRoughPrice = (182 208) distToBorder = 20) contrast(atcontrast(r)) post 
matrix myV = e(V)
matrix myB = e(b)
replace estimate = myB[1,1] in 4
replace upper = myB[1,1] + sqrt(myV[1,1])*1.96 in 4
replace lower = myB[1,1] - sqrt(myV[1,1])*1.96 in 4

reg ACLED_viol_any_ln c.Diamonds##c.diamondRoughPrice##c.distToBorder $controls_iv if KP_compliant==0, vce(cluster id)
margins, at(Diamonds = (0) diamondRoughPrice = (182 208) distToBorder = 135)  contrast(atcontrast(r)) post
matrix myV = e(V)
matrix myB = e(b)
replace estimate = myB[1,1] in 5
replace upper = myB[1,1] + sqrt(myV[1,1])*1.96 in 5
replace lower = myB[1,1] - sqrt(myV[1,1])*1.96 in 5

reg ACLED_viol_any_ln c.Diamonds##c.diamondRoughPrice##c.distToBorder $controls_iv if KP_compliant==0, vce(cluster id)
margins, at(Diamonds = (1) diamondRoughPrice = (182 208) distToBorder = 135)  contrast(atcontrast(r)) post 
matrix myV = e(V)
matrix myB = e(b)
replace estimate = myB[1,1] in 6
replace upper = myB[1,1] + sqrt(myV[1,1])*1.96 in 6
replace lower = myB[1,1] - sqrt(myV[1,1])*1.96 in 6

reg ACLED_viol_any_ln c.Diamonds##c.diamondRoughPrice##c.distToBorder $controls_iv if KP_compliant==0, vce(cluster id)
margins, at(Diamonds = (2) diamondRoughPrice = (182 208) distToBorder = 135)  contrast(atcontrast(r)) post 
matrix myV = e(V)
matrix myB = e(b)
replace estimate = myB[1,1] in 7
replace upper = myB[1,1] + sqrt(myV[1,1])*1.96 in 7
replace lower = myB[1,1] - sqrt(myV[1,1])*1.96 in 7

reg ACLED_viol_any_ln c.Diamonds##c.diamondRoughPrice##c.distToBorder $controls_iv if KP_compliant==0, vce(cluster id)
margins, at(Diamonds = (3) diamondRoughPrice = (182 208) distToBorder = 135)  contrast(atcontrast(r)) post 
matrix myV = e(V)
matrix myB = e(b)
replace estimate = myB[1,1] in 8
replace upper = myB[1,1] + sqrt(myV[1,1])*1.96 in 8
replace lower = myB[1,1] - sqrt(myV[1,1])*1.96 in 8

capture drop xaxis
gen double xaxis = .
replace xaxis = 1 in 1
replace xaxis = 2 in 2
replace xaxis = 3 in 3
replace xaxis = 4 in 4
replace xaxis = 1.30 in 5
replace xaxis = 2.30 in 6
replace xaxis = 3.30 in 7
replace xaxis = 4.30 in 8

* Make scatter plot for first stage
twoway scatter estimate xaxis if xaxis==1 | xaxis==2 | xaxis==3 | xaxis==4, msize(medlarge) msymbol(Oh) color(black) || ///
	   rspike upper lower xaxis if xaxis==1 | xaxis==2 | xaxis==3 | xaxis==4, vertical lwidth(medthick) lcolor(gray) ||  ///
	   scatter estimate xaxis if xaxis==1.3 | xaxis==2.3 | xaxis==3.3 | xaxis==4.3, msize(medlarge) msymbol(Th) color(gray) || ///
	   rspike upper lower xaxis if xaxis==1.3 | xaxis==2.3 | xaxis==3.3 | xaxis==4.3, vertical lwidth(medthick) lcolor(gray)  ///
							yline(0) ///
							xtitle("Diamond mine prevalence", size(medsmall) ) ///
							ytitle("Marginal effect of diamond price increase" "from minimum to maximum in 2016-2018" , size(medsmall)) ///
							xlabel(1 "0" 2 "<5" 3 "6-20" 4 "21-40", labsize(medsmall) )  xline(0) ///
							legend( order(1 "Effect near border"  3 "Effect in centre" 4 "95% CI"  ) size(medsmall) ) 
graph export ".\Figures\Figure_H3_Firststage.png", replace



***************************************************************
** Control methods with and without control variables
***************************************************************

*********************************************
** Main Ms Table 4 and Appendix Table B4 ****
*********************************************

* First stage (linear regression), generate residuals
reg ACLED_viol_any_ln i.Diamonds##c.diamondRoughPrice##c.distToBorder if KP_compliant==0, vce(cluster id)	 
capture drop resid 
predict resid, resid 
outreg2 using "Tables/Table4_Firststage.doc", replace ctitle("Model 4a (First stage)") label dec(3) ///
addtext(Location FE, No) alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)
* First stage (2sls regression), get F-statistic (add manually to table)
ivregress 2sls LocalPeacebuild_AnyAss_ln (ACLED_viol_any_ln = i.Diamonds##c.diamondRoughPrice##c.distToBorder) if KP_compliant==0, first vce(cluster id)	 
estat firststage 

* Control Method by Woolridge (pooled)
nbreg LocalPeacebuild_AnyAssistance ACLED_viol_any_ln resid if KP_compliant==0, vce(cluster id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/Table4.doc", replace ctitle("Model 4a") label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') ///
alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

* First stage (linear regression), generate residuals WITH CONTROLS
reg ACLED_viol_any_ln i.Diamonds##c.diamondRoughPrice##c.distToBorder $controls_iv if KP_compliant==0, vce(cluster id)	 
capture drop resid
predict resid, resid
outreg2 using "Tables/Table4_Firststage.doc", append ctitle("Model 4b (First stage)") label dec(3) ///
addtext(Location FE, No) alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)
* First stage (2sls regression), get F-statistic (add manually to table)
ivregress 2sls LocalPeacebuild_AnyAss_ln $controls_iv (ACLED_viol_any_ln = i.Diamonds##c.diamondRoughPrice##c.distToBorder) if KP_compliant==0, first vce(cluster id)	 
estat firststage 

* Control Method by Woolridge (pooled)
nbreg LocalPeacebuild_AnyAssistance ACLED_viol_any_ln $controls_iv resid if KP_compliant==0, vce(cluster id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/Table4.doc", append ctitle("Model 4b") label dec(3) addtext(Location FE, No) ///
addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)


**********************************************************
* Make plot with results for H3: Instrumented violence
**********************************************************

capture drop estimate
capture drop upper
capture drop lower
capture gen estimate = .
capture gen upper = .
capture gen lower = .

nbreg LocalPeacebuild_AnyAssistance ACLED_viol_any_ln  $controls_iv if KP_compliant==0, vce(cluster id)
margins, at(ACLED_viol_any_ln = (-4.6 0) (mean) _all)  contrast(atcontrast(r)) post
matrix myV = e(V)
matrix myB = e(b)
replace estimate = myB[1,1] in 1
replace upper = myB[1,1] + sqrt(myV[1,1])*1.96 in 1
replace lower = myB[1,1] - sqrt(myV[1,1])*1.96 in 1


* Make Y-Axis
capture drop yaxis
gen yaxis = 1 in 1

twoway scatter yaxis estimate, msize(medlarge) || rspike upper lower yaxis, horizontal lwidth(medthick) lcolor(gray) ///
							ylabel(1.6 "Predicted difference" 1.5 "in peacebuilding events" 1.4 "for increase in:" ///
								   1.1  "*instrumented* "  1 "violence (M4b)" , ///
							labsize(medsmall) labstyle(right) ) ///
							yscale(range(0.5 2) lstyle(none)) /// 
							xtitle("Effect size", size(medsmall) ) ytitle("") ///
							xlabel(-0.5(0.5)1, labsize(medsmall) ) xline(0)  ///
							legend( order(1 "Predicted value" 2 "95% CI") size(medsmall) ) 
graph export "./Figures/Figure_H3.png", replace



****************************
****************************
******** APPENDIX **********
****************************
****************************


******************************************************************************
******************************************************************************
** APPENDIX C: Hypothesis 1: First differences of peacebuilding and violence
******************************************************************************
******************************************************************************

* Woolridge test for H0: No autocorrelation
* USER WRITTEN : search xtserial
xtserial LocalPeacebuild_AnyAssistance ACLED_viol_any, output
// Note that we cannot reject the null hypothesis and conclude that there is no autocorrelation
// Thus, the first difference model is less efficient than the FE model

sort id date
reg D1.LocalPeacebuild_AnyAssistance D1.ACLED_viol_any, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableC1_DiffApp.doc", replace  ctitle(Model C1a) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

 reg D1.LocalPeacebuild_AnyAssistance D1.ACLED_viol_any $controlsl1, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableC1_DiffApp.doc", append ctitle(Model C1b) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

 xtreg D1.LocalPeacebuild_AnyAssistance D1.ACLED_viol_any, fe vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableC1_DiffApp.doc", append ctitle(Model C1c) label dec(3) addtext(Location FE, Yes) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

 xtreg D1.LocalPeacebuild_AnyAssistance D1.ACLED_viol_any $controls_fel1, fe vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableC1_DiffApp.doc", append  ctitle(Model C1d) label dec(3) addtext(Location FE, Yes) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

 


********************************************************************************************
********************************************************************************************
** APPENDIX D: Hypothesis 2: Violence, contemporaneous UN military, and contemporaneous PB
*******************************************************************************************
*******************************************************************************************

* Model effect of violence on UN military deployments
probit un_military_base ACLED_viol_any $controls_med_contemp, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableD1_ContempoApp.doc", replace ctitle(Model D1a) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

* Model effect of violence and UN military deployments on civilian peacekeepers' peacebuilding efforts
nbreg LocalPeacebuild_AnyAssistance ACLED_viol_any un_military_base $controls_med_contemp, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableD1_ContempoApp.doc", append ctitle(Model D1b) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)


* Model effect of violence on UN military personnel numbers
reg un_military_ln ACLED_viol_any $controls_med_contemp, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableD1_ContempoApp.doc", append ctitle(Model D1c) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

* Model effect of violence and UN military personnel numbers on civilian peacekeepers' peacebuilding efforts
set seed 4321
nbreg LocalPeacebuild_AnyAssistance ACLED_viol_any un_military_ln $controls_med_contemp, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableD1_ContempoApp.doc", append ctitle(Model D1d) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

**************************************
**** Appendix D, Figure D1 ***********
**************************************

* Merge average direct effect and average mediation effect (violence in contemporary month)
capture drop  effects low up
capture drop id_merge
gen id_merge = _n
merge m:1 id_merge using ".\MediationAnalysis\mediation_military_ci_App.dta"
drop _merge

* Make Y-Axis
capture drop yaxis
gen yaxis = 4 in 1
replace yaxis = 3 in 2
replace yaxis = 2 in 3
replace yaxis = 1 in 4

* Make scatter plot with mediation effects
twoway scatter yaxis effects, msize(medlarge) || rspike up low yaxis, horizontal lwidth(medthick) lcolor(gray) ///
							ylabel(4 "Average mediation effect of" 3.8 "UN military base" 3 "Direct effect" 2.8 "of violence" ///
								   2 "Average mediation effect of" 1.8 "UN military personnel" 1 "Direct effect" 0.8 "of violence", ///
							labsize(medsmall) labstyle(right) ) ///
							yscale(range(0.5 2.5) lstyle(none)) /// 
							xtitle("Effect size", size(medsmall) ) ytitle("") ///
							xlabel(-0.3(0.1)0.2, labsize(medsmall) ) xline(0)  ///
							legend( order(1 "Predicted value" 2 "95% CI") size(medsmall) ) 
graph export ".\Figures\Figure_H2_AppContempo.png", replace



*****************************************************************************************************************
*****************************************************************************************************************
** APPENDIX E: Hypothesis 2: Controlling for military presence and personnel rather than mediation analyses *****
*****************************************************************************************************************
*****************************************************************************************************************

* Model E1a
nbreg LocalPeacebuild_AnyAssistance ACLED_viol_any un_military_base, vce(cl id)
#delimit ;
estat ic; mat es_ic = r(S); local AIC: display %4.1f es_ic[1,5]; local BIC: display %4.1f es_ic[1,6]; 
#delimit cr
outreg2 using "Tables/TableE_AppControlMil.doc", replace  ctitle(Model E1a) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

* Model E1b
nbreg LocalPeacebuild_AnyAssistance ACLED_viol_any un_military_base $controls, vce(cl id)
# delimit ; 
estat ic; mat es_ic = r(S); local AIC: display %4.1f es_ic[1,5]; local BIC: display %4.1f es_ic[1,6] ; 
#delimit cr
outreg2 using "Tables/TableE_AppControlMil.doc", append  ctitle(Model E1b) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)
 
* Model E1c
nbreg LocalPeacebuild_AnyAssistance ACLED_viol_any un_military, vce(cl id)
#delimit ;
estat ic; mat es_ic = r(S); local AIC: display %4.1f es_ic[1,5]; local BIC: display %4.1f es_ic[1,6]; 
#delimit cr
outreg2 using "Tables/TableE_AppControlMil.doc", append  ctitle(Model E1c) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

* Model E1c
nbreg LocalPeacebuild_AnyAssistance ACLED_viol_any un_military $controls, vce(cl id)
# delimit ; 
estat ic; mat es_ic = r(S); local AIC: display %4.1f es_ic[1,5]; local BIC: display %4.1f es_ic[1,6] ; 
#delimit cr
outreg2 using "Tables/TableE_AppControlMil.doc", append  ctitle(Model E1d) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)
 


********************************************************************************************
********************************************************************************************
** APPENDIX F: Hypothesis 3: Two-stage Least Squares Estimation of IV approach
*******************************************************************************************
*******************************************************************************************


* IV regression (pooled)
set seed 1234
ivregress 2sls LocalPeacebuild_AnyAss_ln (ACLED_viol_any_ln = i.Diamonds##c.diamondRoughPrice##c.distToBorder) if KP_compliant==0, first vce(cluster id)
outreg2 using "Tables/TableF_2SLS.doc", replace ctitle(Model F1a) label dec(3) addtext(Location FE, No) alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)
// Wald chi2(1) = 64.83, Prob > chi2 = 0.0000 needs to be added manually

* IV regression (pooled) WITH CONTROLS
set seed 1234
ivregress 2sls LocalPeacebuild_AnyAss_ln $controls_iv (ACLED_viol_any_ln = i.Diamonds##c.diamondRoughPrice##c.distToBorder) if KP_compliant==0, first  
outreg2 using "Tables/TableF_2SLS.doc", append ctitle(Model F1b) label dec(3) addtext(Location FE, No) alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

* IV regression (fixed effects) WITH CONTROLS
xtivreg LocalPeacebuild_AnyAss_ln $controls_feiv (ACLED_viol_any_ln = i.Diamonds##c.diamondRoughPrice##c.distToBorder) if KP_compliant==0, fe first vce(cluster id)
outreg2 using "Tables/TableF_2SLS.doc", append ctitle(Model F1c) label dec(3) addtext(Location FE, Yes) alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)



********************************************************************************************
********************************************************************************************
** APPENDIX G: Different types of peacebuilding activities (reproduce tables 1 and 2)
*******************************************************************************************
*******************************************************************************************

 
** SocialCohesion_AnyAssistance 

* Model 1a
nbreg SocialCohesion_AnyAssistance ACLED_viol_any  , vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableG1_SocCoh.doc", replace  ctitle(Model G1a) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)


* Model 1b
nbreg SocialCohesion_AnyAssistance ACLED_viol_any $controls, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableG1_SocCoh.doc", append  ctitle(Model G1b) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

* Plot
capture drop estimate
capture drop upper
capture drop lower
capture drop upper90
capture drop lower90
capture drop yaxis
gen yaxis = 4 in 4
replace yaxis = 3 in 3
replace yaxis = 2 in 2
replace yaxis = 1 in 1
gen estimate = .
gen upper = .
gen lower = .
gen upper90 = .
gen lower90 = .
quietly: nbreg SocialCohesion_AnyAssistance ACLED_viol_any $controls, vce(cl id)
margins, predict(n) at(ACLED_viol_any = (0 1)  (mean) _all ) contrast(atcontrast(r)) post
matrix myV = e(V)
matrix myB = e(b)
replace estimate = myB[1,1] in 1
replace upper = myB[1,1] + sqrt(myV[1,1])*1.96 in 1
replace lower = myB[1,1] - sqrt(myV[1,1])*1.96 in 1
replace upper90 = myB[1,1] + sqrt(myV[1,1])*1.645 in 1
replace lower90 = myB[1,1] - sqrt(myV[1,1])*1.645 in 1

							
* Model 1c
set seed 1234
xtnbreg SocialCohesion_AnyAssistance ACLED_viol_any  $controls_fe, fe vce(bootstrap, reps(100)) 
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableG1_SocCoh.doc", append  ctitle(Model G1c) label dec(3) addtext(Location FE, Yes) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

* Plot
quietly: xtnbreg SocialCohesion_AnyAssistance ACLED_viol_any  $controls_fe, fe vce(bootstrap, reps(100)) 
margins, predict(nu0) at(ACLED_viol_any = (0 1)  (mean) _all ) contrast(atcontrast(r)) post
matrix myV = e(V)
matrix myB = e(b)
replace estimate = myB[1,1] in 2
replace upper = myB[1,1] + sqrt(myV[1,1])*1.96 in 2
replace lower = myB[1,1] - sqrt(myV[1,1])*1.96 in 2
replace upper90 = myB[1,1] + sqrt(myV[1,1])*1.645 in 2
replace lower90 = myB[1,1] - sqrt(myV[1,1])*1.645 in 2



* Model 2a
nbreg SocialCohesion_AnyAssistance ACLED_viol_any_l1, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableG2_SocCoh.doc", replace ctitle(Model G2a) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)


* Model 2b
nbreg SocialCohesion_AnyAssistance ACLED_viol_any_l1 $controlsl1, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableG2_SocCoh.doc", append ctitle(Model G2b) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

* Plot
quietly: nbreg SocialCohesion_AnyAssistance ACLED_viol_any_l1 $controlsl1, vce(cl id)
margins, predict(n) at(ACLED_viol_any_l1= (0 1)  (mean) _all ) contrast(atcontrast(r)) post
matrix myV = e(V)
matrix myB = e(b)
replace estimate = myB[1,1] in 3
replace upper = myB[1,1] + sqrt(myV[1,1])*1.96 in 3
replace lower = myB[1,1] - sqrt(myV[1,1])*1.96 in 3
replace upper90 = myB[1,1] + sqrt(myV[1,1])*1.645 in 3
replace lower90 = myB[1,1] - sqrt(myV[1,1])*1.645 in 3


* Model 2c
set seed 1234
xtnbreg SocialCohesion_AnyAssistance ACLED_viol_any_l1 $controls_fel1, fe  vce(bootstrap, reps(10)) 
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableG2_SocCoh.doc", append ctitle(Model G2c) label dec(3) addtext(Location FE, Yes) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

* Plot Type 2
set seed 1234
quietly: xtnbreg SocialCohesion_AnyAssistance ACLED_viol_any_l1 $controls_fel1, fe  vce(bootstrap, reps(10)) 
margins, predict(nu0) at(ACLED_viol_any_l1 = (0 1)  (mean) _all ) contrast(atcontrast(r)) post
matrix myV = e(V)
matrix myB = e(b)
replace estimate = myB[1,1] in 4
replace upper = myB[1,1] + sqrt(myV[1,1])*1.96 in 4
replace lower = myB[1,1] - sqrt(myV[1,1])*1.96 in 4
replace upper90 = myB[1,1] + sqrt(myV[1,1])*1.645 in 4
replace lower90 = myB[1,1] - sqrt(myV[1,1])*1.645 in 4

* Make scatter plot with mediation effects
twoway scatter yaxis estimate, msize(medlarge) || rspike upper lower yaxis, horizontal lwidth(medthick) lcolor(black) || rspike upper90 lower90 yaxis, horizontal lwidth(thick) lcolor(gray) ///
							ylabel(5 "Predicted difference" 4.8 "in reconciliation events" 4.6 "for increase in" 4.4 " violence from 0 to 1:" ///
								   4 "Model G2c (FE, 1m lag)" 3 "Model G2b (1m lag)" 2 "Model G1c (FE)" 1 "Model G1b", ///
							labsize(medsmall) labstyle(right) ) ///
							yscale(range(0.5 5) lstyle(none)) /// 
							xtitle("Effect size", size(medsmall) ) ytitle("") ///
							xline(0)  ///
							legend( order(1 "Predicted value" 2 "95% CI" 3 "90% CI" ) size(medsmall) ) 
graph export "./Figures/FigureG1_social_cohesion.png", replace



** Conflict Management assistance to armed actors


* Model 1a
nbreg ConflictManage_AnyAssistance ACLED_viol_any, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableG3_ConMan.doc", replace  ctitle(Model G3a) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)


* Model 1b
nbreg ConflictManage_AnyAssistance ACLED_viol_any $controls, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableG3_ConMan.doc", append  ctitle(Model G3b) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

* Plot
capture drop yaxis
gen yaxis = 4 in 4
replace yaxis = 3 in 3
replace yaxis = 2 in 2
replace yaxis = 1 in 1
quietly: nbreg ConflictManage_AnyAssistance ACLED_viol_any $controls, vce(cl id)
margins, predict(n) at(ACLED_viol_any = (0 1) (mean) _all) contrast(atcontrast(r)) post
matrix myV = e(V)
matrix myB = e(b)
replace estimate = myB[1,1] in 1
replace upper = myB[1,1] + sqrt(myV[1,1])*1.96 in 1
replace lower = myB[1,1] - sqrt(myV[1,1])*1.96 in 1
replace upper90 = myB[1,1] + sqrt(myV[1,1])*1.645 in 1
replace lower90 = myB[1,1] - sqrt(myV[1,1])*1.645 in 1
							
* Model 1c
set seed 1234
xtnbreg ConflictManage_AnyAssistance ACLED_viol_any  $controls_fe, fe vce(bootstrap, reps(100)) 
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableG3_ConMan.doc", append  ctitle(Model G1c) label dec(3) addtext(Location FE, Yes) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

* Plot
quietly: xtnbreg ConflictManage_AnyAssistance ACLED_viol_any  $controls_fe, fe vce(bootstrap, reps(100)) 
margins, predict(nu0) at(ACLED_viol_any = (0 1) (mean) _all ) contrast(atcontrast(r)) post
matrix myV = e(V)
matrix myB = e(b)
replace estimate = myB[1,1] in 2
replace upper = myB[1,1] + sqrt(myV[1,1])*1.96 in 2
replace lower = myB[1,1] - sqrt(myV[1,1])*1.96 in 2
replace upper90 = myB[1,1] + sqrt(myV[1,1])*1.645 in 2
replace lower90 = myB[1,1] - sqrt(myV[1,1])*1.645 in 2



* Model 2a
nbreg ConflictManage_AnyAssistance ACLED_viol_any_l1, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableG4_ConMan.doc", replace ctitle(Model G4a) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)


* Model 2b
nbreg ConflictManage_AnyAssistance ACLED_viol_any_l1 $controlsl1, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableG4_ConMan.doc", append ctitle(Model G4b) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

* Plot
quietly: nbreg ConflictManage_AnyAssistance ACLED_viol_any_l1 $controlsl1, vce(cl id)
margins, predict(n) at(ACLED_viol_any_l1 = (0 1) (mean) _all ) contrast(atcontrast(r)) post
matrix myV = e(V)
matrix myB = e(b)
replace estimate = myB[1,1] in 3
replace upper = myB[1,1] + sqrt(myV[1,1])*1.96 in 3
replace lower = myB[1,1] - sqrt(myV[1,1])*1.96 in 3
replace upper90 = myB[1,1] + sqrt(myV[1,1])*1.645 in 3
replace lower90 = myB[1,1] - sqrt(myV[1,1])*1.645 in 3

* Model 2c
set seed 1234
xtnbreg ConflictManage_AnyAssistance ACLED_viol_any_l1 $controls_fel1, fe  vce(bootstrap, reps(100)) 
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableG4_ConMan.doc", append ctitle(Model G4c) label dec(3) addtext(Location FE, Yes) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

* Plot Type 2
set seed 1234
quietly: xtnbreg ConflictManage_AnyAssistance ACLED_viol_any_l1 $controls_fel1, fe  vce(bootstrap, reps(100)) 
margins, predict(nu0) at(ACLED_viol_any_l1 = (0 1) (mean) _all ) contrast(atcontrast(r)) post
matrix myV = e(V)
matrix myB = e(b)
replace estimate = myB[1,1] in 4
replace upper = myB[1,1] + sqrt(myV[1,1])*1.96 in 4
replace lower = myB[1,1] - sqrt(myV[1,1])*1.96 in 4
replace upper90 = myB[1,1] + sqrt(myV[1,1])*1.645 in 4
replace lower90 = myB[1,1] - sqrt(myV[1,1])*1.645 in 4

* Make scatter plot with mediation effects
twoway scatter yaxis estimate, msize(medlarge) || rspike upper lower yaxis, horizontal lwidth(medthick) lcolor(black) || rspike upper90 lower90 yaxis, horizontal lwidth(thick) lcolor(gray) ///
							ylabel(5 "Predicted difference" 4.8 "in conflict manage. events" 4.6 "for increase in" 4.4 " violence from 0 to 1:" ///
								   4 "Model G4c (FE, 1m lag)" 3 "Model G4b (1m lag)" 2 "Model G3c (FE)" 1 "Model G3b", ///
							labsize(medsmall) labstyle(right) ) ///
							yscale(range(0.5 5) lstyle(none)) /// 
							xtitle("Effect size", size(medsmall) ) ytitle("") ///
							xline(0)  ///
							legend( order(1 "Predicted value" 2 "95% CI" 3 "90% CI") size(medsmall) ) 
graph export "./Figures/FigureG2_confl_manage.png", replace
							


							
** Civilian protection assistance

* Model 1a
nbreg POC_AnyAssistance ACLED_viol_any, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableG5_CivPro.doc", replace  ctitle(Model G5a) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)


* Model 1b
nbreg POC_AnyAssistance ACLED_viol_any $controls, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableG5_CivPro.doc", append  ctitle(Model G5b) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

* Plot
capture drop yaxis
gen yaxis = 4 in 4
replace yaxis = 3 in 3
replace yaxis = 2 in 2
replace yaxis = 1 in 1
quietly: nbreg POC_AnyAssistance ACLED_viol_any $controls, vce(cl id)
margins, predict(n) at(ACLED_viol_any = (0 1) (mean) _all) contrast(atcontrast(r)) post
matrix myV = e(V)
matrix myB = e(b)
replace estimate = myB[1,1] in 1
replace upper = myB[1,1] + sqrt(myV[1,1])*1.96 in 1
replace lower = myB[1,1] - sqrt(myV[1,1])*1.96 in 1
replace upper90 = myB[1,1] + sqrt(myV[1,1])*1.645 in 1
replace lower90 = myB[1,1] - sqrt(myV[1,1])*1.645 in 1
							
* Model 1c
set seed 1234
xtnbreg POC_AnyAssistance ACLED_viol_any  $controls_fe, fe vce(bootstrap, reps(10)) 
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableG5_CivPro.doc", append  ctitle(Model G5c) label dec(3) addtext(Location FE, Yes) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

* Plot
quietly: xtnbreg POC_AnyAssistance ACLED_viol_any, fe vce(bootstrap, reps(10)) 
margins, predict(nu0) at(ACLED_viol_any = (0 1) (mean) _all ) contrast(atcontrast(r)) post
matrix myV = e(V)
matrix myB = e(b)
replace estimate = myB[1,1] in 2
replace upper = myB[1,1] + sqrt(myV[1,1])*1.96 in 2
replace lower = myB[1,1] - sqrt(myV[1,1])*1.96 in 2
replace upper90 = myB[1,1] + sqrt(myV[1,1])*1.645 in 2
replace lower90 = myB[1,1] - sqrt(myV[1,1])*1.645 in 2



* Model 2a
nbreg POC_AnyAssistance ACLED_viol_any_l1, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableG6_CivPro.doc", replace ctitle(Model G6a) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)


* Model 2b
nbreg POC_AnyAssistance ACLED_viol_any_l1 $controlsl1, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableG6_CivPro.doc", append ctitle(Model G6b) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

* Plot
quietly: nbreg POC_AnyAssistance ACLED_viol_any_l1 $controlsl1, vce(cl id)
margins, predict(n) at(ACLED_viol_any_l1 = (0 1) (mean) _all ) contrast(atcontrast(r)) post
matrix myV = e(V)
matrix myB = e(b)
replace estimate = myB[1,1] in 3
replace upper = myB[1,1] + sqrt(myV[1,1])*1.96 in 3
replace lower = myB[1,1] - sqrt(myV[1,1])*1.96 in 3
replace upper90 = myB[1,1] + sqrt(myV[1,1])*1.645 in 3
replace lower90 = myB[1,1] - sqrt(myV[1,1])*1.645 in 3

* Model 2c
set seed 1234
xtnbreg POC_AnyAssistance ACLED_viol_any_l1 $controls_fel1, fe  vce(bootstrap, reps(10)) 
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableG6_CivPro.doc", append ctitle(Model G6c) label dec(3) addtext(Location FE, Yes) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

* Plot Type 2
set seed 1234
quietly: xtnbreg POC_AnyAssistance ACLED_viol_any_l1 $controls_fel1, fe  vce(bootstrap, reps(10)) 
margins, predict(nu0) at(ACLED_viol_any_l1 = (0 1) (mean) _all ) contrast(atcontrast(r)) post
matrix myV = e(V)
matrix myB = e(b)
replace estimate = myB[1,1] in 4
replace upper = myB[1,1] + sqrt(myV[1,1])*1.96 in 4
replace lower = myB[1,1] - sqrt(myV[1,1])*1.96 in 4
replace upper90 = myB[1,1] + sqrt(myV[1,1])*1.645 in 4
replace lower90 = myB[1,1] - sqrt(myV[1,1])*1.645 in 4

* Make scatter plot with mediation effects
twoway scatter yaxis estimate, msize(medlarge) || rspike upper lower yaxis, horizontal lwidth(medthick) lcolor(black) || rspike upper90 lower90 yaxis, horizontal lwidth(thick) lcolor(gray) ///
							ylabel(5 "Predicted difference" 4.8 "in conflict manage. events" 4.6 "for increase in" 4.4 " violence from 0 to 1:" ///
								   4 "Model G6c (FE, 1m lag)" 3 "Model G6b (1m lag)" 2 "Model G5c (FE)" 1 "Model G5b", ///
							labsize(medsmall) labstyle(right) ) ///
							yscale(range(0.5 5) lstyle(none)) /// 
							xtitle("Effect size", size(medsmall) ) ytitle("") ///
							xline(0)  ///
							legend( order(1 "Predicted value" 2 "95% CI" 3 "90% CI") size(medsmall) ) 
graph export "./Figures/FigureG3_POC.png", replace


** State authority extension

* Model 1a
nbreg StateAuthority_AnyAssistance ACLED_viol_any, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableG7_StateAuth.doc", replace  ctitle(Model G5a) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)


* Model 1b
nbreg StateAuthority_AnyAssistance ACLED_viol_any $controls, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableG7_StateAuth.doc", append  ctitle(Model G5b) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

* Plot
capture drop yaxis
gen yaxis = 4 in 4
replace yaxis = 3 in 3
replace yaxis = 2 in 2
replace yaxis = 1 in 1
quietly: nbreg StateAuthority_AnyAssistance ACLED_viol_any $controls, vce(cl id)
margins, predict(n) at(ACLED_viol_any = (0 1) (mean) _all) contrast(atcontrast(r)) post
matrix myV = e(V)
matrix myB = e(b)
replace estimate = myB[1,1] in 1
replace upper = myB[1,1] + sqrt(myV[1,1])*1.96 in 1
replace lower = myB[1,1] - sqrt(myV[1,1])*1.96 in 1
replace upper90 = myB[1,1] + sqrt(myV[1,1])*1.645 in 1
replace lower90 = myB[1,1] - sqrt(myV[1,1])*1.645 in 1
							
* Model 1c
set seed 1234
xtnbreg StateAuthority_AnyAssistance ACLED_viol_any  $controls_fe, fe vce(bootstrap, reps(10)) 
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableG7_StateAuth.doc", append  ctitle(Model G5c) label dec(3) addtext(Location FE, Yes) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

* Plot
quietly: xtnbreg StateAuthority_AnyAssistance ACLED_viol_any  $controls_fe, fe vce(bootstrap, reps(10)) 
margins, predict(nu0) at(ACLED_viol_any = (0 1) (mean) _all ) contrast(atcontrast(r)) post
matrix myV = e(V)
matrix myB = e(b)
replace estimate = myB[1,1] in 2
replace upper = myB[1,1] + sqrt(myV[1,1])*1.96 in 2
replace lower = myB[1,1] - sqrt(myV[1,1])*1.96 in 2
replace upper90 = myB[1,1] + sqrt(myV[1,1])*1.645 in 2
replace lower90 = myB[1,1] - sqrt(myV[1,1])*1.645 in 2



* Model 2a
nbreg StateAuthority_AnyAssistance ACLED_viol_any_l1, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableG8_StateAuth.doc", replace ctitle(Model G6a) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)


* Model 2b
nbreg StateAuthority_AnyAssistance ACLED_viol_any_l1 $controlsl1, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableG8_StateAuth.doc", append ctitle(Model G6b) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

* Plot
quietly: nbreg StateAuthority_AnyAssistance ACLED_viol_any_l1 $controlsl1, vce(cl id)
margins, predict(n) at(ACLED_viol_any_l1 = (0 1) (mean) _all ) contrast(atcontrast(r)) post
matrix myV = e(V)
matrix myB = e(b)
replace estimate = myB[1,1] in 3
replace upper = myB[1,1] + sqrt(myV[1,1])*1.96 in 3
replace lower = myB[1,1] - sqrt(myV[1,1])*1.96 in 3
replace upper90 = myB[1,1] + sqrt(myV[1,1])*1.645 in 3
replace lower90 = myB[1,1] - sqrt(myV[1,1])*1.645 in 3

* Model 2c
set seed 1234
xtnbreg StateAuthority_AnyAssistance ACLED_viol_any_l1 $controls_fel1, fe  vce(bootstrap, reps(10)) 
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableG8_StateAuth.doc", append ctitle(Model G6c) label dec(3) addtext(Location FE, Yes) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

* Plot Type 2
set seed 1234
quietly: xtnbreg StateAuthority_AnyAssistance ACLED_viol_any_l1 $controls_fel1, fe  vce(bootstrap, reps(10)) 
margins, predict(nu0) at(ACLED_viol_any_l1 = (0 1) (mean) _all ) contrast(atcontrast(r)) post
matrix myV = e(V)
matrix myB = e(b)
replace estimate = myB[1,1] in 4
replace upper = myB[1,1] + sqrt(myV[1,1])*1.96 in 4
replace lower = myB[1,1] - sqrt(myV[1,1])*1.96 in 4
replace upper90 = myB[1,1] + sqrt(myV[1,1])*1.645 in 4
replace lower90 = myB[1,1] - sqrt(myV[1,1])*1.645 in 4

* Make scatter plot with mediation effects
twoway scatter yaxis estimate, msize(medlarge) || rspike upper lower yaxis, horizontal lwidth(medthick) lcolor(black) || rspike upper90 lower90 yaxis, horizontal lwidth(thick) lcolor(gray) ///
							ylabel(5 "Predicted difference" 4.8 "in conflict manage. events" 4.6 "for increase in" 4.4 " violence from 0 to 1:" ///
								   4 "Model G8c (FE, lag 1m)" 3 "Model G8b (lag 1m)" 2 "Model G7c (FE)" 1 "Model G7b", ///
							labsize(medsmall) labstyle(right) ) ///
							yscale(range(0.5 5) lstyle(none)) /// 
							xtitle("Effect size", size(medsmall) ) ytitle("") ///
							xline(0)  ///
							legend( order(1 "Predicted value" 2 "95% CI" 3 "90% CI") size(medsmall) ) 
graph export "./Figures/FigureG4_StateAuth.png", replace
							

 



******************************************************************
******************************************************************
****** Appendix H: Different types of violence
******************************************************************
******************************************************************


*  ACLED_viol_nonState 

* Model 1a
nbreg LocalPeacebuild_AnyAssistance ACLED_viol_nonState, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableH1_ViolNS.doc", replace  ctitle(Model H1a) label dec(3) addtext(Location FE, NO) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

* Model 1b
nbreg LocalPeacebuild_AnyAssistance ACLED_viol_nonState $controls, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableH1_ViolNS.doc", append  ctitle(Model H1b) label dec(3) addtext(Location FE, NO) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)
						
* Model 1c
set seed 1234
xtnbreg LocalPeacebuild_AnyAssistance ACLED_viol_nonState $controls_fe, fe vce(bootstrap, reps(50)) 
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableH1_ViolNS.doc", append  ctitle(Model H1c) label dec(3) addtext(Location FE, NO) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

  
	
							
*  ACLED_violenceAgainstCiv

* Model 1a
nbreg LocalPeacebuild_AnyAssistance ACLED_violenceAgainstCiv, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableH2_ViolAgCiv.doc", replace  ctitle(Model H2a) label dec(3) addtext(Location FE, NO) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

* Model 1b
nbreg LocalPeacebuild_AnyAssistance ACLED_violenceAgainstCiv $controls, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableH2_ViolAgCiv.doc", append  ctitle(Model H2b) label dec(3) addtext(Location FE, NO) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)
						
* Model 1c
set seed 1234
xtnbreg LocalPeacebuild_AnyAssistance ACLED_violenceAgainstCiv $controls_fe, fe vce(bootstrap, reps(50)) 
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableH2_ViolAgCiv.doc", append  ctitle(Model H2c) label dec(3) addtext(Location FE, NO) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

  						

						
*  State-based violence

* Model 1a
nbreg LocalPeacebuild_AnyAssistance ACLED_viol_stateBased, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableH3_ViolState.doc", replace  ctitle(Model C1a) label dec(3) addtext(Location FE, NO) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

* Model 1b
nbreg LocalPeacebuild_AnyAssistance ACLED_viol_stateBased $controls, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableH3_ViolState.doc", append  ctitle(Model C1a) label dec(3) addtext(Location FE, NO) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)
						
* Model 1c
set seed 1234
xtnbreg LocalPeacebuild_AnyAssistance ACLED_viol_stateBased $controls_fe, fe vce(bootstrap, reps(50)) 
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableH3_ViolState.doc", append  ctitle(Model C1b) label dec(3) addtext(Location FE, NO) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

 

			
********************************************			
********************************************
* Appendix J: UCDP Violence
********************************************
********************************************

* Model 1a
nbreg LocalPeacebuild_AnyAssistance UCDP_viol_any, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableJ1_UCDP.doc", replace  ctitle(Model J1a) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)
 
* Model 1b
nbreg LocalPeacebuild_AnyAssistance UCDP_viol_any $controls_ucdp, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableJ1_UCDP.doc", append  ctitle(Model J1b) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)

* Model 1b
pwcorr anyCheckpoint UCDP_viol_any, sig // Multicol
nbreg LocalPeacebuild_AnyAssistance UCDP_viol_any $controls_ucdp2, vce(cl id)
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableJ1_UCDP.doc", append  ctitle(Model J1c) label dec(3) addtext(Location FE, No) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)
 
							
* Model 1c
set seed 1234
xtnbreg LocalPeacebuild_AnyAssistance UCDP_viol_any $controls_ucdp_fe, fe vce(bootstrap, reps(50)) 
estat ic
mat es_ic = r(S)
local AIC: display %4.1f es_ic[1,5]
local BIC: display %4.1f es_ic[1,6]
outreg2 using "Tables/TableJ1_UCDP.doc", append  ctitle(Model J1d) label dec(3) addtext(Location FE, Yes) addstat(AIC, `AIC', BIC, `BIC') alpha(0.01, 0.05, 0.1) symbol(**, *, +) eqdrop(lnalpha)



